<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>拉货明细列表</title>
        <% include("/common/common_css_js.html"){} %>
    </head>
    <body>
        <div style="padding-bottom: 5px;">
            <div id="queryForm" class="uc-toolbaroverflow" _borderStyle="border-top:0;">

                <span>主单号：</span><input id="keyMasterBillCode" name="keyMasterBillCode" emptyText="请输入主单号"  class="mini-textbox" selectOnFocus="true" required="false" requiredErrorText="主单号不能为空" />
                <span class="separator"></span>
                <span>主单类型：</span><input id="keyMasterBillTypeId" name="keyMasterBillTypeId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                         required="false" allowInput="false" showNullItem="false" nullItemText="请选择..." requiredErrorText="没有选择主单类型"/>
                <span class="separator"></span>
                <span>拉货日期：</span>
                <input id="keyPullStartDate" name="keyPullStartDate"  class="mini-datepicker"   format="yyyy-MM-dd"/>--<input id="keyPullEndDate" name="keyPullEndDate" class="mini-datepicker"  format="yyyy-MM-dd"/>

                <span class="separator"></span>
                <span>分单号：</span><input id="keyNativeBillCode" name="keyNativeBillCode" emptyText="请输入分单号"  class="mini-textbox" selectOnFocus="true" required="false" requiredErrorText="分单号不能为空" />

                <div style="margin-top: 5px"></div>

                <% if(so.hasPermission("bMasterBillPullDetail:query")){%>
                    <a class="mini-button" iconCls="icon-search" onclick="searchMasterPull()">查询</a>
                <% } %>

                <% if(so.hasPermission("bMasterBillPullDetail:queryCndClear")){%>
                    <a class="mini-button" iconCls="icon-new" onclick="clearSearch()">清空查询条件</a>
                <% } %>

                <span class="separator"></span>

                <% if(so.hasPermission("bMasterBillPullDetail:download")){%>
                    <#download_grid id="downloadGrid" theGridId="datagrid1" theFileName="拉货明细信息表"/>
                <% } %>

            </div>
        </div>

        <div class = "mini-fit">
            <div id="datagrid1" class="mini-datagrid"
                 style="width: 100%; height: 100%;"
                 url="${base}/pages/master_bill_manage/pull/detail/queryPullDetailJoinList" idField="id"
                 showPager="true" pageSize="20" sizeList="[10,20,30,50,100]"
                 multiSelect = "true" allowResize="true"
                 allowSortColumn = "true"
                 sortField="createTime"
                 sortOrder="desc"
            >
                <div property="columns">

                    <div field="masterBillId" width="140" headerAlign="center" align="center" allowSort="true"   renderer="showMasterBillRender">主单号</div>
                    <div field="masterBillTypeId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">主单类型</div>
                    <div field="pullDisposeAmount" width="140" headerAlign="center" align="right" allowSort="true" renderer="public_moneyRenderer">主单调整金额</div>
                    <div field="pullDisposeComment" width="140" headerAlign="center" align="left" >主单拉货说明</div>

                    <div field="nativeBillId" width="140" headerAlign="center" align="center" renderer="showNativeBillRender">分单号</div>
                    <div field="pullNumber" width="140" headerAlign="center" align="right" >分单拉货件数</div>
                    <div field="pullActualWeight" width="140" headerAlign="center" align="right" >分单拉货实重</div>
                    <div field="pullChargeableWeight" width="140" headerAlign="center" align="right" >分单拉货计重</div>
                    <div field="pullVolume" width="140" headerAlign="center" align="right" >分单拉货体积</div>
                    <div field="pullAmount" width="140" headerAlign="center" align="right" renderer="public_moneyRenderer">分单拉货调整金额</div>
                    <div field="pullComment" width="140" headerAlign="center" align="left" >分单拉货说明</div>

                    <div field="pullDisposeReasonIds" width="180" headerAlign="center" align="left" allowSort="true"  data-options='{cacheName:"sysDic"}' renderer="commonRenderXtDicCacheNameByIds">分单拉货原因</div>
                    <div field="pullDisposeId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">分单拉货处置类型</div>
                    <div field="pullDisposeAirportId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"airport"}' renderer="commonRender">分单拉货始发机场</div>
                    <div field="pullDisposeAirlinesId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"airlines"}' renderer="commonRender">分单拉货航空公司</div>
                    <div field="pullDisposeFlightDate" width="140" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss" renderer="ondayRenderer">分单拉货处置日期</div>
                    <div field="pullDisposeFlightName" width="140" headerAlign="center" align="center" allowSort="true" >拉货处置班次</div>

                    <div field="createTime" width="140" headerAlign="center" align="center" allowSort="false" dateFormat="yyyy-MM-dd HH:mm:ss" renderer="ondayRenderer">创建时间</div>
                    <div field="createUserId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">创建用户</div>
                </div>
            </div>

        </div>




        <script type="text/javascript">
            mini.parse();

            let keyMasterBillCode = mini.get("keyMasterBillCode");
            let keyMasterBillTypeId = mini.get("keyMasterBillTypeId");
            let keyOpenBillStartDate = mini.get("keyOpenBillStartDate");
            let keyOpenBillEndDate = mini.get("keyOpenBillEndDate");
            let keyNativeBillCode = mini.get("keyNativeBillCode");

            let grid = mini.get("datagrid1");

            $(function () {

                // 运输种类下拉列表
                let keyMasterBillTypeIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_MASTER_BILL_TYPE");
                keyMasterBillTypeId.load(keyMasterBillTypeIdJsonData);

                // 加载列表数据
                grid.load();
            });


            function clearSearch(){
                let form = new mini.Form("#queryForm");
                form.clear();
            }

            /**
             * 根据查询条件查询分单
             */
            function searchMasterPull(){
                let form = new mini.Form("#queryForm");
                let data = form.getData(true);
                grid.load(data);
            }


            /**
             * 261,260,航空主单,航空主单
             262,260,汽运主单,汽运主单
             * @type {{auto: number, air: number}}
             */
            let masterBillType ={air:261,auto:262};

            // 展示主单号时显示其超链接
            function showMasterBillRender(e){
                // renderer="showMasterBillRender"

                let masterBillId = e.value;
                let billType = e.record.masterBillTypeId;
                let htmlStr = "<a href='javascript:void(0);' onclick='showViewMasterBill(\""+ masterBillId +"\"," + billType + ")'>" + masterBillId + "</a>";

                return htmlStr;
            }

            function showViewMasterBill(masterBillId,billType){
                let tabUrl= "";
                let tabTitle = "";
                if(billType==masterBillType.air){
                    tabUrl="${base}/pages/master_bill_manage/flight/showUpdateMasterBill?opType=view&id=" + masterBillId;
                    tabTitle = "航空主单查看";
                }
                else{
                    tabUrl="${base}/pages/master_bill_manage/auto/showUpdateMasterBill?opType=view&id=" + masterBillId;
                    tabTitle = "汽运主单查看";
                }

                parent.window.addTabToMainPage(tabTitle,tabTitle,tabUrl);
            }


            function showNativeBillRender(e){
                //  renderer="showNativeBillRender"
                let nativeBillId = e.value;
                let htmlStr = "<a href='javascript:void(0);' onclick='showViewNativeBill(\""+ nativeBillId +"\")'>" + nativeBillId + "</a>";
                return htmlStr;
            }

            function showViewNativeBill(nativeBillId){
                let tabUrl="${base}/pages/native_bill_manage/showUpdateBill?opType=view&id=" + nativeBillId;
                parent.window.addTabToMainPage("分单查看","分单查看",tabUrl);
            }


        </script>



    </body>
</html>